<template>
	<view>
		<view class="c-box-nobg">
			<view class="" v-for="item in serve.keys()">
				<c-label :title="item"></c-label>
				<u-grid :col="4" :border="false">
					<u-grid-item v-for="item1 in serve.get(item)" class="mt16"  @click="toServe(item1.link)">
						<u-image :src="$http+item1.imgUrl" height="88rpx" width="88rpx"></u-image>
						<text class="mt8" style="font-size: 28rpx;">{{item1.serviceName}}</text>
					</u-grid-item>
				</u-grid>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import { getServe } from '../../api';
import {onLoad} from '@dcloudio/uni-app'

	const serve = ref(new Map())
	const getServeDate = async()=>{
		const res =await  getServe()
		let map = new Map
		res.rows.map(item=>{
			let serviceType=item.serviceType
			if(map.has(serviceType)){
				map.get(serviceType).push(item)
			}
			else if(serviceType==null)
			{
				map.set('其他',[item])
			}
			else {
				map.set(serviceType,[item])
			}
			serve.value =map
		})
	}
	onLoad(()=>{
		getServeDate()
	})
	const toServe = (url)=>{
		console.log(url);
		uni.navigateTo({
			url:'/subpages/'+url
		})
	}
</script>

<style>

</style>
